package panels;

import islemler.DegisiklikTalebiYonet;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;

import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.LayoutStyle;

import panels.DegisiklikTalebiListelePanel.GuncellemeIslemi;
import panels.KullaniciIslemPanel.guncelleButonuKontrol;

import nesne.DegisiklikTalebi;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class DegTalebiGuncellemePaneli extends javax.swing.JPanel {
	private JComboBox guncelleBox;
	private JLabel statuLabel;
	private DegisiklikTalebi degTalebi;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new DegTalebiGuncellemePaneli(new DegisiklikTalebi()));
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public DegTalebiGuncellemePaneli(DegisiklikTalebi degTalebi) {
		super();
		this.degTalebi=degTalebi;
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)this);
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(400, 300));
			{
				String[] durum;
				if(degTalebi.getStatusu() == 1) {
					if(degTalebi.getDegerlendirme().trim().equals(""))
						durum = new String[]{"Yeni"};
					else
						durum = new String[]{"Yeni", "Degerlendirmede"};	
				}
				
				else if(degTalebi.getStatusu() == 2) {
						durum = new String[]{"Degerlendirmede","Yapilmakta","KabulEdilmedi"};
				}
				
				else if(degTalebi.getStatusu() == 3){
					if(degTalebi.getYapilanIslemler().trim().equals(""))
						durum = new String[]{"Yapilmakta"};
						else
					durum = new String[]{"Yapilmakta","Yapildi"};
				
				}
				else if(degTalebi.getStatusu() == 4){
					if(degTalebi.getTestSonucu().trim().equals(""))
						durum = new String[]{"yapildi"};
					else
					durum = new String[]{"Yapildi","Test edildi"};
					
				}
				else 
					durum = new String[]{"Yeni"};
				
				ComboBoxModel guncelleBoxModel = 
					new DefaultComboBoxModel(durum);
				guncelleBox = new JComboBox();
				guncelleBox.setModel(guncelleBoxModel);
				guncelleBox.addActionListener(new GuncelleButonuKontrol());
			}
			{
				statuLabel = new JLabel();
				statuLabel.setText("Statu :");
			}
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(64, 64)
					.addComponent(statuLabel, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)
					.addGap(96, 96, GroupLayout.PREFERRED_SIZE)
					.addComponent(guncelleBox, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(126, Short.MAX_VALUE));
				thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(65, 65)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(guncelleBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
				    .addComponent(statuLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))
				.addContainerGap(183, Short.MAX_VALUE));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public class GuncelleButonuKontrol implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			DegisiklikTalebiYonet degTalYon = new DegisiklikTalebiYonet();
			degTalYon.Klone(degTalebi,guncelleBox.getSelectedIndex()+1);
		}
	}
}